import request from '@/utils/request'

// 获取文件列表
export function getFileList({ page, pageSize, query }) {
  return request({
    url: `/folder_file/${page}/${pageSize}`,
    method: 'get',
    params: query
  })
}

// 新增文件夹
export function addFolders(data) {
  return request({
    url: `/folders`,
    method: 'post',
    data
  })
}

// 编辑文件夹
export function editFolders(id, data) {
  return request({
    url: `/folders/${id}`,
    method: 'put',
    data
  })
}

// 删除文件夹
export function delFolders(id) {
  return request({
    url: `/folders/${id}`,
    method: 'delete'
  })
}

// 根据id获取文件夹
export function getFolderDetail(id) {
  return request({
    url: `/folders/${id}`,
    method: 'get'
  })
}

// 查询文件夹权限列表
export function folderGetPermissions({ page, pageSize, query }) {
  return request({
    url: `folder_permissions/${page}/${pageSize}`,
    method: 'get',
    params: query
  })
}

// 查询文件权限列表
export function fileGetPermissions({ page, pageSize, query }) {
  return request({
    url: `file_permissions/${page}/${pageSize}`,
    method: 'get',
    params: query
  })
}

// 获取部门人员列表(文件夹)
export function folderGetDepartmentUsers(folderId) {
  return request({
    url: `folder_permissions/get_department_users/${folderId}`,
    method: 'get'
  })
}

// 获取部门人员列表(文件)
export function fileGetDepartmentUsers(fileId) {
  return request({
    url: `file_permissions/get_department_users/${fileId}`,
    method: 'get'
  })
}

// 新增文件夹权限
export function folderPermissions(data) {
  return request({
    url: `folder_permissions`,
    method: 'post',
    data
  })
}

// 新增文件权限
export function filePermissions(data) {
  return request({
    url: `file_permissions`,
    method: 'post',
    data
  })
}

// 启用、停用文件权限
export function filePermissionsEditStatus(id, status) {
  return request({
    url: `file_permissions/edit_status/${id}/${status}`,
    method: 'put'
  })
}

// 启用、停用文件夹权限
export function folderPermissionsEditStatus(id, status) {
  return request({
    url: `folder_permissions/edit_status/${id}/${status}`,
    method: 'put'
  })
}

// 删除文件夹权限
export function delFolderPermissions(id) {
  return request({
    url: `folder_permissions/${id}`,
    method: 'delete'
  })
}

// 删除文件权限
export function delFilePermissions(id) {
  return request({
    url: `file_permissions/${id}`,
    method: 'delete'
  })
}

// 上传文件
export function addFiles(data) {
  return request({
    url: `files`,
    method: 'post',
    data
  })
}

// 删除文件
export function delFiles(id) {
  return request({
    url: `files/${id}`,
    method: 'delete'
  })
}